package com.aspose.cells;

class zadq extends zbz {
   private CellArea a;
   private byte[] d;
   private byte[] e;

   zadq(CellArea var1, String var2, String var3, Hyperlink var4) {
      this.c(440);
      this.a(var1, var2, var3, var4);
   }

   private void a(Hyperlink var1) {
      String var2 = null;
      int var3 = var1.getAddress().indexOf(35);
      String var4 = var1.getAddress();
      String var5 = var1.getTextToDisplay();
      boolean var6 = var5 != null && !"".equals(var5);
      if (var3 != -1) {
         var2 = var4.substring(var3 + 1);
         var4 = var4.substring(0, 0 + var3);
      }

      byte[] var7 = Encoding.getUnicode().a(var4);
      int var8 = 0;
      byte[] var9 = var7;
      int var10 = var7.length;

      int var11;
      byte var12;
      for(var11 = 0; var11 < var10; ++var11) {
         var12 = var9[var11];
         if (var12 != 0) {
            ++var8;
         }
      }

      boolean var13 = var8 != var7.length / 2;
      byte[] var14 = new byte[var8];
      var8 = 0;

      for(var11 = 0; var11 < var7.length; ++var11) {
         var12 = var7[var11];
         if (var12 != 0) {
            var14[var8] = var12;
            ++var8;
         }
      }

      this.c(440);
      this.b(32);
      if (var6) {
         this.b(this.d() + (short)(6 + var5.length() * 2));
      }

      this.b(this.d() + 18);
      this.b(this.d() + (short)(var14.length + 1 + 4));
      this.b(this.d() + 28);
      if (var13) {
         this.b(this.d() + (short)(6 + var4.length() * 2 + 2));
      }

      if (var2 != null) {
         this.b(this.d() + (short)(4 + var2.length() * 2 + 2));
      }

      this.c = new byte[this.d()];
      this.a = var1.getArea();
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.a.StartRow), 0, this.c, 0, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(this.a.EndRow), 0, this.c, 2, 2);
      this.c[4] = (byte)this.a.StartColumn;
      this.c[6] = (byte)this.a.EndColumn;
      this.d = new byte[]{-48, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11, 2, 0, 0, 0};
      System.arraycopy(this.d, 0, this.c, 8, 20);
      this.d = null;
      this.c[28] = 3;
      if (var2 != null) {
         this.c[28] = (byte)(this.c[28] | 8);
      }

      var11 = 32;
      if (var6) {
         this.c[28] = (byte)(this.c[28] | 20);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var5.length() + 1), 0, this.c, var11, 4);
         var11 += 4;
         System.arraycopy(Encoding.getUnicode().a(var5), 0, this.c, var11, var5.length() * 2);
         var11 += var5.length() * 2 + 2;
      }

      this.d = new byte[]{3, 3, 0, 0, 0, 0, 0, 0, -64, 0, 0, 0, 0, 0, 0, 70};
      System.arraycopy(this.d, 0, this.c, var11, 16);
      this.d = null;
      var11 += 18;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var14.length + 1), 0, this.c, var11, 4);
      var11 += 4;
      System.arraycopy(var14, 0, this.c, var11, var14.length);
      var11 += var14.length + 1;
      this.d = new byte[24];
      this.d[0] = -1;
      this.d[1] = -1;
      this.d[2] = -83;
      this.d[3] = -34;
      System.arraycopy(this.d, 0, this.c, var11, 24);
      var11 += 24;
      if (var13) {
         var8 = var7.length + 6;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var8), 0, this.c, var11, 4);
         var11 += 4;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var7.length), 0, this.c, var11, 4);
         var11 += 4;
         this.c[var11] = 3;
         var11 += 2;
         System.arraycopy(var7, 0, this.c, var11, var7.length);
         var11 += var7.length;
      } else {
         var11 += 4;
      }

      if (var2 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length() + 1), 0, this.c, var11, 4);
         var11 += 4;
         System.arraycopy(Encoding.getUnicode().a(var2), 0, this.c, var11, var2.length() * 2);
      }

   }

   private void a(CellArea var1, String var2, String var3) {
      String var4 = null;
      int var5 = var3.lastIndexOf(35);
      if (var5 != -1) {
         var4 = var3.substring(var5 + 1);
         var3 = var3.substring(0, 0 + var5);
      }

      this.a((short)(44 + 2 * (var2.length() + var3.length())));
      if (var4 != null) {
         this.b(this.d() + (short)(4 + var4.length() * 2 + 2));
      }

      this.c = new byte[this.d()];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.StartRow), 0, this.c, 0, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.EndRow), 0, this.c, 2, 2);
      this.c[4] = (byte)var1.StartColumn;
      this.c[6] = (byte)var1.EndColumn;
      this.d = new byte[]{-48, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11, 2, 0, 0, 0};
      System.arraycopy(this.d, 0, this.c, 8, 20);
      this.c[28] = 23;
      this.c[29] = 1;
      if (var4 != null) {
         this.c[28] = (byte)(this.c[28] | 8);
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length() + 1), 0, this.c, 32, 4);
      System.arraycopy(Encoding.getUnicode().a(var2), 0, this.c, 36, 2 * var2.length());
      int var6 = 38 + 2 * var2.length();
      System.arraycopy(com.aspose.cells.b.a.zc.a(var3.length() + 1), 0, this.c, var6, 4);
      var6 += 4;
      System.arraycopy(Encoding.getUnicode().a(var3), 0, this.c, var6, 2 * var3.length());
      var6 += 2 + 2 * var3.length();
      if (var4 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var4.length() + 1), 0, this.c, var6, 4);
         var6 += 4;
         System.arraycopy(Encoding.getUnicode().a(var4), 0, this.c, var6, var4.length() * 2);
      }

   }

   private void b(CellArea var1, String var2, String var3) {
      int var4 = 0;
      int var6 = var3.lastIndexOf("..\\");
      String var5;
      if (var6 != -1) {
         var4 = var6 / 3 + 1;
         var5 = var3.substring(var6 + 3);
      } else {
         var5 = var3;
      }

      String[] var7 = com.aspose.cells.b.a.zv.d(var5, '#');
      var5 = var7[0];
      String var8 = null;
      if (var7.length > 1) {
         var8 = var7[1];
      }

      byte[] var9 = Encoding.getASCII().a(var5);
      byte[] var10 = Encoding.getUnicode().a(var5);
      boolean var11 = true;

      int var12;
      for(var12 = 0; var12 < var10.length; var12 += 2) {
         if (var10[var12 + 1] != 0) {
            var11 = false;
            break;
         }

         if (var10[var12] != var9[var12 / 2]) {
            var11 = false;
            break;
         }
      }

      this.a((short)(89 + 2 * var2.length() + var9.length));
      if (!var11) {
         this.b(this.d() + (short)(6 + var10.length));
      }

      if (var8 != null) {
         this.b(this.d() + (short)(4 + var8.length() * 2 + 2));
      }

      this.c = new byte[this.d()];
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.StartRow), 0, this.c, 0, 2);
      System.arraycopy(com.aspose.cells.b.a.zc.a(var1.EndRow), 0, this.c, 2, 2);
      this.c[4] = (byte)var1.StartColumn;
      this.c[6] = (byte)var1.EndColumn;
      this.d = new byte[]{-48, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11, 2, 0, 0, 0};
      System.arraycopy(this.d, 0, this.c, 8, 20);
      this.c[28] = 21;
      if (var8 != null) {
         this.c[28] = (byte)(this.c[28] | 8);
      }

      System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length() + 1), 0, this.c, 32, 4);
      System.arraycopy(Encoding.getUnicode().a(var2), 0, this.c, 36, 2 * var2.length());
      var12 = 38 + 2 * var2.length();
      this.c[var12] = 3;
      ++var12;
      this.c[var12] = 3;
      var12 += 7;
      this.c[var12] = -64;
      var12 += 7;
      this.c[var12] = 70;
      ++var12;
      System.arraycopy(com.aspose.cells.b.a.zc.a((short)var4), 0, this.c, var12, 2);
      var12 += 2;
      System.arraycopy(com.aspose.cells.b.a.zc.a(var9.length + 1), 0, this.c, var12, 4);
      var12 += 4;
      System.arraycopy(var9, 0, this.c, var12, var9.length);
      var12 += var9.length + 1;
      this.c[var12] = -1;
      ++var12;
      this.c[var12] = -1;
      ++var12;
      this.c[var12] = -83;
      ++var12;
      this.c[var12] = -34;
      ++var12;
      var12 += 20;
      if (var11) {
         var12 += 4;
      } else {
         System.arraycopy(com.aspose.cells.b.a.zc.a(6 + var10.length), 0, this.c, var12, 4);
         var12 += 4;
         System.arraycopy(com.aspose.cells.b.a.zc.a(var10.length), 0, this.c, var12, 4);
         var12 += 4;
         this.c[var12++] = 3;
         this.c[var12++] = 0;
         System.arraycopy(var10, 0, this.c, var12, var10.length);
         var12 += var10.length;
      }

      if (var8 != null) {
         System.arraycopy(com.aspose.cells.b.a.zc.a(var8.length() + 1), 0, this.c, var12, 4);
         System.arraycopy(Encoding.getUnicode().a(var8), 0, this.c, var12 + 4, var8.length() * 2);
      }

   }

   private void a(CellArea var1, String var2, String var3, Hyperlink var4) {
      if (var2 == null || "".equals(var2)) {
         var2 = var3;
      }

      if (var3.startsWith("\\\\")) {
         this.a(var1, var2, var3);
      } else if (var3.length() > 1 && var3.charAt(1) == ':') {
         this.a(var4);
      } else {
         boolean var5;
         String var6;
         if (var3.indexOf(".") != -1) {
            var5 = true;
            var6 = var3.toLowerCase();
            if (!var6.startsWith("http:") && !var6.startsWith("www.") && !var6.startsWith("https:") && !var6.startsWith("mailto:")) {
               if (var3.indexOf("!") != -1) {
                  int var7 = var3.lastIndexOf(35);
                  if (var7 == -1) {
                     String[] var8 = com.aspose.cells.b.a.zv.d(var3, '!');
                     if (var8[1] != null && !"".equals(var8[1]) && zakq.d(var8[1])) {
                        var5 = false;
                     }
                  }
               }
            } else {
               var5 = false;
            }

            if (var5) {
               this.b(var1, var2, var3);
               return;
            }
         }

         var5 = false;
         var6 = var3.toLowerCase();
         com.aspose.cells.b.a.g.a.zc var10 = com.aspose.cells.b.a.g.a.ze.a(var6, "^\\w+:", 66);
         if (!var10.c() && !var6.startsWith("www.")) {
            var5 = true;
         }

         if (var5) {
            this.a((short)(44 + 2 * (var2.length() + var3.length())));
         } else {
            this.a((short)(60 + 2 * (var2.length() + var3.length())));
         }

         this.c = new byte[this.d()];
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1.StartRow), 0, this.c, 0, 2);
         System.arraycopy(com.aspose.cells.b.a.zc.a(var1.EndRow), 0, this.c, 2, 2);
         this.c[4] = (byte)var1.StartColumn;
         this.c[6] = (byte)var1.EndColumn;
         this.d = new byte[]{-48, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11, 2, 0, 0, 0};
         System.arraycopy(this.d, 0, this.c, 8, 20);
         if (var5) {
            this.c[28] = 28;
         } else {
            this.c[28] = 23;
         }

         System.arraycopy(com.aspose.cells.b.a.zc.a(var2.length() + 1), 0, this.c, 32, 4);
         System.arraycopy(Encoding.getUnicode().a(var2), 0, this.c, 36, 2 * var2.length());
         int var9 = 38 + 2 * var2.length();
         this.e = new byte[]{-32, -55, -22, 121, -7, -70, -50, 17, -116, -126, 0, -86, 0, 75, -87, 11};
         if (!var5) {
            System.arraycopy(this.e, 0, this.c, var9, 16);
            var9 += 16;
         }

         if (var5) {
            System.arraycopy(com.aspose.cells.b.a.zc.a(var3.length() + 1), 0, this.c, var9, 4);
         } else {
            System.arraycopy(com.aspose.cells.b.a.zc.a(2 * var3.length() + 2), 0, this.c, var9, 4);
         }

         var9 += 4;
         System.arraycopy(Encoding.getUnicode().a(var3), 0, this.c, var9, 2 * var3.length());
         int var10000 = var9 + 2 * var3.length() + 2;
      }
   }

   zadq() {
      this.c(440);
   }
}
